package com.example.LifeCycle.Bean;

import com.example.LifeCycle.commons.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * @Description TODO
 * @Date 2024/5/15 10:42
 * @Created by houjunfeng
 */
@Configuration
public class BeanConfigeration {
    //singleton 容器启动时创建对象，并在对象创建好和属性设置好值以后 执行初始化方法，容器销毁时调用销毁方法
    //prototype 每次获取对象才会创建对象，并执行初始化；容器销毁并不调用销毁方法
    @Scope("prototype")
    @Bean(name="Person",initMethod = "init",destroyMethod = "destory")
    public Person getPerson(){
        return  new Person();
    }
}
